"""
1.用js控制日期选择
2.用js滑动滑块
3.上传文件
"""
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from pywinauto.keyboard import send_keys
from selenium.webdriver import ActionChains

driver = webdriver.Chrome()
url = ("file:///C:/Users/Mr%20MING/PycharmProjects/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/learn-git/js%E6%93%8D%E4%BD%9C/%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6%E5%89%AF%E6%9C%AC.html")
driver.get(url)

# 3.文件上传操作
# input可以通过send_keys,发送文件路径
# f = driver.find_element(By.ID, "mfile")
# f.send_keys(r"C:\Users\Mr MING\PycharmProjects\自动化测试\learn-git\js操作\js操作.py")
# time.sleep(2)
# driver.quit()

# 方法二
f = driver.find_element(By.ID, "mfile")
time.sleep(2)
# 点击弹出上传文件弹窗
ac = ActionChains(driver)
ac.click(f).perform()
time.sleep(2)
# 调用pywinauto的send_keys
send_keys(r"C:\Temp\TxGameDownload\APK\业务办理授权函")
# 如果多个文件上传就输入多个send_keys
# send_keys(r"C:\Users\Mr MING\PycharmProjects\自动化测试\learn-git\web自动化基础\鼠标操作\笔记.text")
# send_keys(r"C:\Users\Mr MING\PycharmProjects\自动化测试\learn-git\web自动化基础\鼠标操作\笔记.text")
# 确认提交
send_keys("{VK_RETURN}")
time.sleep(2)

"""
1.文件上传路径解析错误，上传的C/，结果解析的是D盘

from pywinauto import Desktop
app = Desjtop()
dialog = app['打开'] 根据名字弹出窗口
dialog["Edit"].type_keys("D/用户.html")  在输入框中输入值
dialog["Button"].click()



"""